<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>客服问题记录列表</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
<input id="username" value="${username}" type="hidden">
    <form action="bizCustomerManage/dolist" method="post" name="searchForm" id="searchForm" role="form" class="form-horizontal">
            <div class="form-group">
                    <label class="col-sm-1 control-label">经销商名称：</label>
                    <div class="col-md-4">
                                <input type="text" class="form-control" name="name" id="name" value="${entity.name}" placeholder="经销商名称">
                    </div>
                    <label class="col-sm-1 control-label">问题类型：</label>
                    <div class="col-md-4">
                                 <d:select clazz="selectpicker" name="problemType" id="problemType" list="${problemTypes}" selected="${entity.problemType}"/>
                    </div>
            </div>
            <div class="form-group">
                    <label class="col-sm-1 control-label">解决进度：</label>
                    <div class="col-md-4">
                                <d:select clazz="selectpicker" name="solveProgress" id="solveProgress"  list="${solveProgresss}" selected="${entity.solveProgress}"/>
                    </div>
                    <label class="col-sm-1 control-label">解决人：</label>
                    <div class="col-md-4">
                                <input type="text" class="form-control" name="solvePerson" id="solvePerson" value="${entity.solvePerson}" placeholder="解决人">
                    </div>
            </div>
            <div class="form-group">
                    <label class="col-sm-1 control-label">反馈时间：</label>
                    <div class="col-md-4">
						<input type="text" class="span1 Wdate" style="width:205px" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:'#F{$dp.$D(\'endBackTime\')}'})" id="beginBackTime" name="beginBackTime" value="${searchEntity.beginBackTime}" placeholder="开始时间" /> 至 
						<input type="text" class="span1 Wdate" style="width:205px" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', minDate:'#F{$dp.$D(\'beginBackTime\')}'})" id="endBackTime" name="endBackTime" value="${searchEntity.endBackTime}" placeholder="结束时间" />
					</div>
                    <label class="col-sm-1 control-label">解决时间：</label>
                    <div class="col-md-4">
                        <input type="text" class="span1 Wdate" style="width:205px" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:'#F{$dp.$D(\'endSolveTime\')}'})" id="beginSolveTime" name="beginSolveTime" value="${searchEntity.beginSolveTime}" placeholder="开始时间" /> 至 
						<input type="text" class="span1 Wdate" style="width:205px" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', minDate:'#F{$dp.$D(\'beginSolveTime\')}'})" id="endSolveTime" name="endSolveTime" value="${searchEntity.endSolveTime}" placeholder="结束时间" />
                    </div>
            </div>
        <div class="form-group">
        	<label class="col-sm-1 control-label">记录人：</label>
            <div class="col-md-4">
                 <input type="text" class="form-control" name="recorder" id="recorder" value="${entity.recorder}" placeholder="记录人">
            </div>
            <label class="col-sm-1 control-label">关键字：</label>
            <div class="col-md-4">
                <div class="input-group">
                    <input type="text" class="form-control" name="keywords" value="${searchEntity.keywords}" placeholder="">
                    <div class="input-group-btn">
                        <button id="searchBtn" type="button" class="btn btn-sm btn-info"><i class="fa fa-search"></i> 搜索</button>
                    </div>
                </div>

            </div>
        </div>
    </form>
    
       <!-- 导出表单 -->
    <form id= "exportexcalform" method=post action="${ctx}/bizCustomerManage/export" target="_blank" >
					<input type="hidden" name="problemType"  />
					<input type="hidden" name="name"  />
					<input type="hidden" name="solveProgress"  />
					<input type="hidden" name="solvePerson"  />
					<input type="hidden" name="beginBackTime"  />
					<input type="hidden" name="endBackTime"  />
					<input type="hidden" name="beginSolveTime"  />
					<input type="hidden" name="endSolveTime"  />
	</form>
    
    
    
    <div class="row">
        <div class="col-md-10">
            <p>
                <shiro:hasPermission name="BIZ_CUSTOMER_MANAGE:add">
                    <button type="button" data-url="bizCustomerManage/create" class="btn btn-sm btn-success link_add" data-title="新增客服问题记录"><i class="fa fa-plus"></i> 新增</button>
                </shiro:hasPermission>
                <shiro:hasPermission name="BIZ_CUSTOMER_MANAGE:edit">
                    <button type="button" data-url="bizCustomerManage/edit" class="btn btn-sm btn-primary link_edit" data-title="编辑客服问题记录"><i class="fa fa-edit"></i> 修改</button>
                </shiro:hasPermission>
                <shiro:hasPermission name="BIZ_CUSTOMER_MANAGE:delete">
                    <button type="button" data-url="bizCustomerManage/delete" class="btn btn-sm btn-danger link_del"><i class="fa fa-trash"></i> 删除</button>
                </shiro:hasPermission>
                <shiro:hasPermission name="BIZ_CUSTOMER_MANAGE:view">
                    <button type="button" data-url="bizCustomerManage/info" class="btn btn-sm link_info" data-title="客服问题记录详情"><i class="fa fa-book"></i> 详情</button>
                </shiro:hasPermission>
                	<button id="export" type="button" url="bizCustomerManage/export" class="btn btn-sm btn-pink link_export" style="margin-left: 2px">导出</button>
            </p>
        </div>
    </div>

    <table id="table_data" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th class="center td-checkbox" width="5%">
                <label><input type="checkbox" class="check-all ace" data-tableid="table_data" /><span class="lbl"></span></label>
            </th>
            <th width="10%">经销商名称</th>
            <th width="8%">问题类型</th>
            <th width="18%">问题详细</th>
            <th width="6%">反馈人</th>
            <!-- <th width="7%">联系方式</th> -->
            <th width="6%">解决进度</th>
            <th width="6%">解决人</th>
            <th width="8%">反馈时间</th>
            <th width="8%">解决时间</th>
            <th width="6%">记录人</th>
            <th width="12%">备注</th>
            <th width="15%">附件</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>
<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        var table = $("#table_data").dataTable({
            ajax: function(data, callback, settings){
                tableAjax($("#searchForm"),data, callback, settings);
            },
            //列表表头字段
            columns: [
                mainConfig.checkboxColumn,
                { "data": "name",name:"name" },
                { "data": "problemTypeStr",name:"problem_type",orderable:false },
                { "data": "problem",name:"problem",orderable:false  },
                { "data": "feedbackPerson",name:"feedback_person",orderable:false },
                /* { "data": "mobile",name:"mobile",orderable:false }, */
                { "data": "solveProgressStr",
                	
                	"render": function (data, type, row, meta) {  
                    	var a = "";  
                    		if(row.solveProgress == "1") {  
                        		var a = '<span style="color:#ff0000">'+row.solveProgressStr+'</span>';  
                   			}else{  
                        		var a = '<span>'+row.solveProgressStr+'</span>';  
                    		}  
                    			return a;  
                	},orderable:false
                },
                { "data": "solvePerson",name:"solve_person",orderable:false },
                { "data": "feedbackDateStr",name:"feedback_date" },
                { "data": "solveDateStr",name:"solve_date" },
                { "data": "recorder",name:"recorder" },
                { "data": "remark",name:"remark",orderable:false },
                { "data": "action",
                    "render": function ( data, type, row, meta ) {
                    	var A = "<a onclick=\"handlerUpload('" + row.id + "');\">上传</a>";
                    	var B = "<a onclick=\"handlerShow('" + row.id + "');\">查看</a>";
                    	var C = "<a onclick=\"handlerDelete('" + row.id + "');\">删除</a>";
                    	if(row.recorder == $("#username").val() && row.attachment == "1"){ 
                    		return A+"&nbsp;"+B+"&nbsp;"+C; 
                    	}
                    	if(row.recorder == $("#username").val() && row.attachment != "1"){ 
                    		return A; 
                    	}
                    	if(row.recorder != $("#username").val() && row.attachment == "1"){ 
                    		return B;
                    	}
                    	return "--";
                    },orderable:false
               }
        ]
    }).api();

        //查询条件
        $("#searchForm").submit(function(){
            table.ajax.reload();
            return false;
        });
    });
    
    //点击导出 将页面数据加载到表单中
	function exportexcal(){
		$('#exportexcalform input[name="problemType"]').val($.trim($("#problemType").val()));
		$('#exportexcalform input[name="name"]').val($.trim($("#name").val()));
		$('#exportexcalform input[name="solveProgress"]').val($.trim($("#solveProgress").val()));
		$('#exportexcalform input[name="solvePerson"]').val($.trim($("#solvePerson").val()));
		$('#exportexcalform input[name="beginBackTime"]').val($.trim($("#beginBackTime").val()));
		$('#exportexcalform input[name="endBackTime"]').val($.trim($("#endBackTime").val()));
		$('#exportexcalform input[name="beginSolveTime"]').val($.trim($("#beginSolveTime").val()));
		$('#exportexcalform input[name="endSolveTime"]').val($.trim($("#endSolveTime").val()));
		$('#exportexcalform').submit();
	}
    
	   // 上传
    function handlerUpload(id){
    	var layerIndex = layer.open({
            title: "附件上传",
            type: 2,
            content: "/bizCustomerManage/upload/"+ id,
            area: [$(window).width()+"px", $(window).height()+"px"]
        });
    }
    
    // 查看
    function handlerShow(id){
    	var layerIndex = layer.open({
            title: "附件查看",
            type: 2,
            content: "/bizCustomerManage/show/"+ id,
            area: [$(window).width()+"px", $(window).height()+"px"]
        });
    }
    
    // 删除
    function handlerDelete(id){
        layer.confirm("确定要删除此记录的附件吗?", function(index) {
            layer.close(index);
            $.ajax({
                url:  "/bizCustomerManage/deleteAttachment",
                type: "post",
                data: {id:id,},
                dataType: "json",
                success: function (data) {
                    if(data.success){
                    	 $('#searchForm').submit();
                    }else{
                        layer.alert(data.msg);
                    }
                }
            });
        });
    }
    
</script>
<!-- script end -->
</body>
</html>